<template>
  <div class="about">
    <h1>This is an about page</h1>
    <el-button @click="getdow()">下载</el-button>
  </div>
</template>
<script>
export default {
  data() {
    return {

    }
  },
  methods:{
    getdow(){
      this.openDownload('https://image.hpdd.com/dscp-test/20230420104159y037cn.pdf','测试.pdf')
    },
    async openDownload(link, name) {
      const x = new XMLHttpRequest();
      x.open('GET', link, true);
      x.responseType = 'blob';
      x.onload = function () {
        const url = window.URL.createObjectURL(x.response);
        const a = document.createElement('a');
        a.href = url;
        a.download = name || '';
        a.click();
      };
      x.send();
    },
  }
}
</script>
